package com.timebank.timecoin.service;

import com.timebank.common.core.constant.SecurityConstants;
import com.timebank.common.core.constant.ServiceNameConstants;
import com.timebank.common.core.result.Result;
import com.timebank.common.core.web.pojo.AjaxResult;
import com.timebank.timecoin.factory.RemoteTimeCoinFallBackFactory;
import com.timebank.timecoin.pojo.entity.TimeCoinTrade;
import com.timebank.timecoin.pojo.vo.TimeCoinTradeVO;
import io.swagger.annotations.Api;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
/**
 * 时间币 服务
 * @author shiliuyinzhen
 */
@FeignClient(contextId = "remoteTimeCoinService", value = ServiceNameConstants.TIMECOIN_SERVICE, fallbackFactory = RemoteTimeCoinFallBackFactory.class)
@Api(tags = "时间币服务")
public interface RemoteTimeCoinService {

    /**
     * 新增时间币交易
     * @param timeCoinTrade
     * @param source
     * @return
     */
    @PostMapping("/trade")
    AjaxResult createTrade(@RequestBody TimeCoinTrade timeCoinTrade, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 批量删除时间币交易
     * @param tradeIds
     * @return
     */
    @DeleteMapping("/trade/{tradeIds}")
    AjaxResult deleteTradeByIds(@PathVariable("tradeIds") Long[] tradeIds, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据志愿服务Id和获得者Id删除时间币交易
     * @param map
     * @param source
     * @return
     */
    @DeleteMapping("/trade")
    AjaxResult deleteTradeByVolunteerIdAndGetterId(@RequestBody Map<String,Long> map, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据志愿服务Id支付时间币
     * @param volunteerId
     * @param source
     * @return
     */
    @PostMapping("/trade/pay/{volunteerId}")
    AjaxResult payTimeCoinByVolunteerId(@PathVariable("volunteerId") Long volunteerId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据志愿服务Ids批量删除时间币交易
     * @param volunteerIds
     * @param source
     * @return
     */
    @DeleteMapping("/trade/volunteer/{volunteerIds}")
    AjaxResult deleteTradeByVolunteerIds(@PathVariable("volunteerIds")Long[] volunteerIds,  @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据用户Ids和志愿服务Id批量删除时间币交易
     * @param userIds
     * @param source
     * @return
     */
    @DeleteMapping("/trade/user/{userIds}")
    AjaxResult deleteTradeByUserIdsAndVolunteerId(@PathVariable("userIds")Long[] userIds, @RequestBody Long volunteerId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 条件查询时间币交易
     * @param timeCoinTrade
     * @param source
     * @return
     */
    @GetMapping("/trade/query")
    Result<List<TimeCoinTradeVO>> getTradeByCondition(@SpringQueryMap TimeCoinTrade timeCoinTrade, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
